<%--
  Created by IntelliJ IDEA.
  User: User
  Date: 2024/5/16
  Time: 14:47
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
    <head>
        <title>Title</title>
    </head>
    <body>

        <h1>欢迎来到网络商城主页</h1>

        <c:choose>
            <c:when test="${empty user}">
                <a href="${pageContext.request.contextPath}/jsp/register.jsp">注册</a>
                <a href="${pageContext.request.contextPath}/jsp/login.jsp">登录</a>
            </c:when>
            <c:otherwise>
                欢迎您:${user.username}
                <a href="${pageContext.request.contextPath}/logout.user">注销</a>
                <a href="${pageContext.request.contextPath}/findMyOrders.order">我的订单</a>
            </c:otherwise>
        </c:choose>
        当前在线人数:${count}
        <table>
            <thead>
                <tr>
                    <th>序号</th>
                    <th>商品</th>
                    <th>商品单价</th>
                    <th>操作</th>
                </tr>
            </thead>
            <tbody>
                <c:forEach items="${products}" var="product" varStatus="i">
                    <tr>
                        <td>${i.index+1}</td>
                        <td>${product.name}</td>
                        <td>${product.price}</td>
                        <td>
                            <a href="${pageContext.request.contextPath}/add.cart?id=${product.id}">加入购物车</a>
                        </td>
                    </tr>
                </c:forEach>
            </tbody>
        </table>
        <span style="color:red;">
            ${productMsg}
        </span>
        <a href="${pageContext.request.contextPath}/jsp/cart.jsp">查看购物车</a>
    </body>
</html>
